/**
 * @author gao
 * @date 2025/6/21 19:41
 */

public class Demo4 {
    public static void main(String[] args) {
        // 创建一个新的线程
        Thread thread = new Thread() {
            @Override
            public void run() {
                while (true) {
                    System.out.println("Hello Tread!");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        };

        // 启动线程
        thread.start();

        while (true) {
            // 在主线程中输出"Hello Main!"
            System.out.println("Hello Main!");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}